import {DirectiveBinding} from "vue";
import store from "../../store";
import {UserPermissionDAT} from "../../types/responseTypes";
import {usePermission} from "../../utils/usePermission";

function checkPermission(el: HTMLElement, binding:DirectiveBinding){
    const {can} = usePermission()
    const need = binding.arg
    if (need){
       if (can(+need)){
           el.parentNode && el.parentNode.removeChild(el)
       }
    }

}

export default {
    mounted(el: HTMLElement, binding:DirectiveBinding){
        checkPermission(el,binding)
    },

    updated(el: HTMLElement, binding:DirectiveBinding){
        checkPermission(el,binding)
    }
}
